/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pt.iasd.youthshelter.datamodel;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Rui
 */
@Entity
@Table(name = "ACTIVITY_PARTICIPATION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ActivityParticipation.findAll", query = "SELECT a FROM ActivityParticipation a"),
    @NamedQuery(name = "ActivityParticipation.findByPathfinderId", query = "SELECT a FROM ActivityParticipation a WHERE a.activityParticipationPK.pathfinderId = :pathfinderId"),
    @NamedQuery(name = "ActivityParticipation.findByActivityId", query = "SELECT a FROM ActivityParticipation a WHERE a.activityParticipationPK.activityId = :activityId")})
public class ActivityParticipation implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ActivityParticipationPK activityParticipationPK;
    @JoinColumn(name = "PATHFINDER_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pathfinder pathfinder;
    @JoinColumn(name = "INVOLVEMENT_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Involvement involvementId;
    @JoinColumn(name = "ACTIVITY_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity;

    public ActivityParticipation() {
    }

    public ActivityParticipation(ActivityParticipationPK activityParticipationPK) {
        this.activityParticipationPK = activityParticipationPK;
    }

    public ActivityParticipation(int pathfinderId, int activityId) {
        this.activityParticipationPK = new ActivityParticipationPK(pathfinderId, activityId);
    }

    public ActivityParticipationPK getActivityParticipationPK() {
        return activityParticipationPK;
    }

    public void setActivityParticipationPK(ActivityParticipationPK activityParticipationPK) {
        this.activityParticipationPK = activityParticipationPK;
    }

    public Pathfinder getPathfinder() {
        return pathfinder;
    }

    public void setPathfinder(Pathfinder pathfinder) {
        this.pathfinder = pathfinder;
    }

    public Involvement getInvolvementId() {
        return involvementId;
    }

    public void setInvolvementId(Involvement involvementId) {
        this.involvementId = involvementId;
    }

    public Activity getActivity() {
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (activityParticipationPK != null ? activityParticipationPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ActivityParticipation)) {
            return false;
        }
        ActivityParticipation other = (ActivityParticipation) object;
        if ((this.activityParticipationPK == null && other.activityParticipationPK != null) || (this.activityParticipationPK != null && !this.activityParticipationPK.equals(other.activityParticipationPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pt.iasd.youthshelter.datamodel.ActivityParticipation[ activityParticipationPK=" + activityParticipationPK + " ]";
    }
    
}
